
<html>
  <head>
    <title>send_recive.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

	<script type="text/javascript" src="/assets/js/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="/assets/js/util.js"></script>
	<script type="text/javascript" src="/assets/js/uploader.js"></script>
	<script type="text/javascript" src="/assets/html/swfupload/swfupload.js"></script>
	<script type="text/javascript">
		var temp=0;
		var href=getHref();
		var usersessionid=href.usersessionid;
		function saveMessageResponse(){
			var saveMessageResponseUrl='/comnetMessageInfo';
			$.ajax({
				type:'get',
				data:'usersessionid='+usersessionid+'&temp='+temp++,
				url:saveMessageResponseUrl,
				error:function(err){
					saveMessageResponse();
				},
				success:function(data){
					var userInfo=eval("("+data+")");
					var now=getNowTime();
					var charNum=userInfo.username.length;
					var spaceTotal='';
					for(var i=0;i<=8;i++){
						spaceTotal+='&nbsp;'
					}
					
					var message=userInfo.username+':&nbsp;'+now+'<br/>';
					for(var name in userInfo){
						if(name=='message'){
							message+=spaceTotal+userInfo.message+'<br/>';
						}else if(name=='filepath'){
							message+=spaceTotal+'<a href='+userInfo.filepath+' target=\'_blank\'>您有新的文件达到,点击下载...</a>'+'<br/>';
						}
					}
					$('#content').append(message.bold());
					document.getElementById('content').scrollTop=document.getElementById('content').scrollHeight;
					$('#show').val('');
					saveMessageResponse();
				}				
			});
		}
		function sendMessage(){
			var sendMessageUrl='/sendMessage';
			var message=$("#show").val();
			message=encodeURI(message);
			$.ajax({
				type:'get',
				data:'message='+message+'&usersessionid='+usersessionid+'&temp='+temp++,
				url:sendMessageUrl,
				error:function(err){
					alert('信息发送失败!');
				},
				success:function(data){
					
				}				
			});
		}
		function edit(){
			 $("#show").keydown(function(){
			    $("#show").css("background-color","#FFFFCC");
		     });
		     $("#show").keyup(function(){
		    	//$("#show").css("background-color","#D6D6FF");
		     });
			
		}
		function cleanScreen(){
			$("#content").html('');
		}
		function sendMessagekeypress(){
			$('html').keypress(function(){
				var sendType=$('#sendType').val();
				if(window.event.keyCode==13&&sendType=='enter'){
					sendMessage();
				}else if(window.event.keyCode==10&&sendType=='enter_crtl'){
					sendMessage();
				}
			});
		}
		function sendFile(){
			var post_params={'uploadtype':'message.html_upload','usersessionid':usersessionid,'temp':temp++};
			swfu.setPostParams(post_params);
			swfu.startUpload();
		}
		$(function(){
			$("body").attr('height',document.body.scrollHeight);
			$("#content_tr").attr('height',document.body.clientHeight*70/100);
			$("#content").css('height',document.body.clientHeight*70/100);
			saveMessageResponse();
			edit();
			sendMessagekeypress();
		});
	</script>
	
  </head>
  
  <body style="overflow-x:hidden">
    <table>
		<tr id="content_tr">
			<td>
				<div id="content" style="overflow-x: auto; overflow-y: auto; "></div>
			</td>
		</tr>
		<tr>
			<td>
				<table>
					<tr>
						<td align="right">
							<textarea id='show' cols="10" rows="5" style="width: 888px;" class='comments'></textarea>
							<textarea id='send' style="display:none;"></textarea>
						</td>
					</tr>
					<tr>
						<td>
							<select id='sendType'>
								<option value='enter_crtl'>Enter+Crtl发送</option>
								<option value='enter'>Enter发送</option>
							</select>
							<button onclick="sendMessage();">发送</button>
							<button type="button" id="spanSWFUploadButton"><img width="13" height="13" src="http://xnimg.cn/n/core/res/upload-bullet.png">发送文件</button>
							<!--<button onclick="sendFile();">发送文件</button>-->
							&nbsp;&nbsp;&nbsp;<button id="cleanScreen" onclick="cleanScreen();">清屏</button>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
  </body>
</html>
